<?php

namespace Narti\BouncerBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;


use Narti\BouncerBundle\Repository\LandlineRepository;
use Narti\BouncerBundle\Entity\Landline;



/**
 * Default controller.
 *
 * @Route("/")
 */
class DefaultController extends Controller
{
    /**
     * Random landline
     *
     * @Route("/", name="default")
     * @Template()
     */
    public function indexAction()
    {
        $em = $this->getDoctrine()->getEntityManager();

        $entity = $em->getRepository('NartiBouncerBundle:Landline')->findRandom();
        
        if(count($entity)== 0){
            $entity = new Landline();
        }
        
        return $this->render('NartiBouncerBundle:Default:index.html.twig', array('entity' => $entity));

    }
    /**
     * Menù item bounce
     *
     * @Route("bouncing", name="bouncing")
     * @Template()
     */
    public function bouncingAction()
    {
        
        return $this->render('NartiBouncerBundle:Default:bouncing.html.twig');

    }
}
